#include "MyUtils.h"

wchar_t* MyUtils::m_to_w(__in char* pszInBuf) {
    int len = MultiByteToWideChar(NULL, NULL, pszInBuf, -1, NULL, 0);
    ++len;
    wchar_t* pszOutBuf = new wchar_t[len];
    memset(pszOutBuf, 0, sizeof(wchar_t) * len);
    if (MultiByteToWideChar(NULL, NULL, pszInBuf, -1, pszOutBuf, len)) {
        return pszOutBuf;
    }
    return NULL;
}

char* MyUtils::w_to_m(__in wchar_t* pszInBuf) {
    int len = WideCharToMultiByte(NULL, NULL, pszInBuf, -1, NULL, 0, NULL, NULL);
    ++len;
    char* pszOutBuf = new char[len];
    memset(pszOutBuf, 0, sizeof(char) * len);
    if (WideCharToMultiByte(NULL, NULL, pszInBuf, -1, pszOutBuf, len, NULL, NULL)) {
        return pszOutBuf;
    }
    return NULL;
}

